import os
#邮件内容配置
APPROVAL_SUB = ["【簽核通知】尊敬的{}：您有一筆單需要簽核，請及時處理，謝謝!",
                "【催單通知】尊敬的{}：您有一筆單急需簽核，請及時處理，謝謝!",
                "{}尊敬的{}：您有{}紙待接收，請及時處理，謝謝!",
                "【簽核通知】尊敬的{}：您有{}待簽核，請及時處理，謝謝!"
                ]

APPROVAL_CONTENT = ["尊敬的{}:\n 您好！\n\t《基準烽火雲台》中您有一筆表單需簽核，請及時處理，謝謝！ \n\t 簽核地址：{}",
                    "尊敬的{}:\n 您好！\n\t《基準烽火雲台》中您有一筆表單急需簽核，請及時處理，謝謝！\n\t 簽核地址{}",
                    "尊敬的{}:\n 您好！\n\t《基準烽火雲台》中您有{}待接收，請及時處理，謝謝！\n\t 接收地址: {}",
                    "尊敬的{}:\n 您好！\n\t《基準烽火雲台》中您有{}需簽核，請及時處理，謝謝！ \n\t 簽核地址: {}"]

WEB_HRAD = [
    "templates/module1/index.html#/forms?tk={}",
    "templates/module1/index.html#/{}?from={}&filter=0&page=1&action=receive&tk={}",
    "templates/module1/index.html#/drawcuscheck/:{}?from=draw_list&tk={}&wr={}&filter=0&page=1",
    "templates/module1/index.html#/drawengcheck/:{}?from=draw_list&tk={}&wr={}&filter=0&page=1"

]

#邮件内容配置

EMAiL_FROM = {
    "system_name": "AC",
    "toMail": "",
    "content": "",
    "mail_title": "",
    "cc": "",
    "html_status": "False",
    "errors_type": "通知郵件"}  # 郵件格式

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'ajan@6$)c)*8fplq(&!^d6&*l@r)5o0zm%*-ak62hraklqx4e$'
STATIC_PATH = os.path.join(BASE_DIR).replace('\\', '/')


# AC用户默认信息
STATUS_ACTIVE = {  # 設置有效狀態的狀態碼，代碼會依據這個來判定是否為有效狀態
    "USER": 100,
    "SYSTEM": 200,
}

DEFAULT_SITE = "LH"
BULK_IMPORT_FIELDS = {
    "SITE": "LH",  # 默认厂区
    "EMAIL": "bulk.import@mail.com",  # 默认邮箱
    "SEX": "Undefined",  # 默认性别
    "DUTY": "員工",  # 默認職務
    "ENTRY_DATE": "2017-06-15",  # 默认的入职日期
    "USER_STATUS_ID": 101,  # 默認狀態為用戶未激活
    "PASSWORD": None,  # 為空則設置用戶工號為默認密碼
    "MAX_ORG_NAME": "基準精密工業",  # 设置最大的组织架构，必须比導入的Excel文件中出现的最大组织大一级
    "ORG_STATUS": True,  # 默认的组织架构状态
}
# AC用户默认信息


STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

STATICFILES_DIRS = (
    ('rest_framework', os.path.join(STATIC_ROOT, 'rest_framework').replace('\\', '/')),
)

SESSION_COOKIE_AGE = 60 * 60 * 2  # 存活时长为120秒*60
SESSION_EXPIRE_AT_BROWSER_CLOSE = True  # 当浏览器关闭时,session存活期即满并删除
SESSION_SAVE_EVERY_REQUEST = True  # 处于活动状态的session暂时不删除.

# Application definition


INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'tb_forms',
    'tb_menu',
    'tb_info',
    'corsheaders',
    'ac',
    'ars',
    'wfs',
    'files',
    'customer',
    'thdata',
    'rest_framework',
    'ims',
    'smart_cutter',
    'deviceinfo',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    #'method.middleware.TokenMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'method.middleware.TokenMiddleware',
)

# 跨域增加忽略
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
    '*'
)

CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
    'VIEW',
)

CORS_ALLOW_HEADERS = (
    'XMLHttpRequest',
    'X_FILENAME',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
    'Pragma',
)



ROOT_URLCONF = 'ST1.urls'

AUTH_USER_MODEL = 'ac.MyUser'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'ST1.wsgi.application'

DJANGO_SETTING_MODULE = 'ac.models'



CORS_ORIGIN_ALLOW_ALL = True

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False



APPEND_SLASH = False

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/


NOT_AUTH_LIST = ("/ac/login",
                 "/ars-auth/login/",
                 "/ac/logout",
                 "/ac/QR_code_login",
                 "/ac/retrieve_pwd",
                 "/ac/set_new_pwd",
                 "/ac/check_token",
                 "/info/add_org_people",
                 "/api/workflow_approval/",
                 "/iot/ids_rate/",
                 "/iot/mpniupi/",
                 "/iot/mpniupdi2/",
                 "/iot/format_gantt/",
                 "/ims/correct_data",
                 "/device/upload/",
                 "/device/listing/",
                 "/device/download/",
                 "/device/query/",
                 "/device/edit/",
                 "/device/match/",
                 )  # 登录验证白名单
